package cpa.prowon.gui.actions;

import cpa.prowon.Application;
import cpa.prowon.gui.MainWindow;

/**
 * Saves the index with the information of the current shown ImageContainers
 * @author Chris
 */
public class SaveIndexAction extends PatchedAction {

	/**
	 * Constructor
	 * @param MainWindow The window where the action is used
	 * @author Chris
	 */
	public SaveIndexAction(MainWindow w) {
		super(w);
	}
	
	/**
	 * Return the title key
	 * @return The title key
	 * @author Chris
	 */
	protected String getTitleKey() {
		return "menu_item_file_saveindex";
	}

	/**
	 * Return the tooltip key
	 * @return The tooltip key
	 * @author Chris
	 */
	protected String getTooltipKey() {
		return "menu_item_file_saveindex_tooltip";
	}

	/**
	 * Return the image key
	 * @return The image key
	 * @author Chris
	 */
	protected String getImageKey() {
		return "file:icons/save.gif";
	}
	
	/**
	 * Run the action
	 * @author Chris
	 */
	public void run() {

		// Show a message in the status line
		window.setStatus(Application.getInstance().getResourceBundle().getString("statusmsg_savingindex"));
		
		// Get all images and save the index
		window.getCategoryPart().getRootIndexCategory().writeIndex();

		// Remove the message from the status line
		window.setStatus("");
		
	}

}
